package com.example.provide;

import com.example.utils.RabbitMqUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;

public class Provider {

    //交换机名称
    private static final String EXCHANGE = "my.topic";

    public static void main(String[] args) {
        Connection connection = RabbitMqUtils.getConnection();
        Channel channel = null;
        try {
            channel = connection.createChannel();
            for (int i = 0; i < 20; i++) {
                channel.basicPublish(EXCHANGE, "v.e.rabbit", null, ("msg" + i).getBytes());
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            RabbitMqUtils.close(connection, channel);
        }
    }


}
